package com.samsung.app;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Environment;
import android.telephony.TelephonyManager;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

public class Utils
{
  private static ArrayList<String> dscPrefixList = null;
  private static String userAgent;

  static
  {
    dscPrefixList = new ArrayList<String>();
    dscPrefixList.add("WB150");
    dscPrefixList.add("DV300");
    dscPrefixList.add("DV500");
    dscPrefixList.add("WB300");
    dscPrefixList.add("ST200");
    dscPrefixList.add("WB850");
    userAgent = null;
  }

  public static String getDefaultStorage()
  {
    if (isNexusOne());
    String str = Environment.getExternalStorageDirectory().getPath() + "/sdcard/RemoteViewfinder";
//    str = Environment.getExternalStorageDirectory().getPath() + "/DCIM/RemoteViewfinder";
      return str;
  }

  public static String getMacAddress(Context paramContext)
  {
    Object localObject = "";
    WifiInfo localWifiInfo = ((WifiManager)paramContext.getSystemService("wifi")).getConnectionInfo();
    if (localWifiInfo != null)
    {
      String str = localWifiInfo.getMacAddress();
      if (str != null)
        localObject = str;
    }
    return (String)localObject;
  }

  public static String getUserAgent()
  {
    return userAgent;
  }

  public static boolean isNexusOne()
  {
    return Build.MODEL.equals("Nexus One");
  }

  public static boolean isSCHi909()
  {
    return Build.MODEL.equals("SCH-i909");
  }

  public static boolean isTab101()
  {
    return Build.MODEL.contains("SHW-M380");
  }

  public static void setUseragent(Context paramContext)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("SEC_RVF_");
    String str1 = null;
    if (paramContext != null)
    {
      TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
      if (localTelephonyManager.getSimState() != 1)
        str1 = localTelephonyManager.getLine1Number();
      if ((str1 == null) || (str1.length() == 0))
      {
        WifiInfo localWifiInfo = ((WifiManager)paramContext.getSystemService("wifi")).getConnectionInfo();
        if (localWifiInfo != null)
        {
          String str2 = localWifiInfo.getMacAddress();
          if (str2 != null)
            str1 = str2.replace(":", "");
        }
      }
    }
    if ((str1 == null) || (str1.length() == 0))
      str1 = "UNKNOWN";
    localStringBuffer.append(str1);
    userAgent = localStringBuffer.toString();
  }

  public static boolean supportDSCPrefix(String paramString)
  {
   for(String dscPrefix : dscPrefixList){
     if (paramString.contains(dscPrefix)){
    	  return true;
      }
    }
   return false;
  }

  public static String unitChange(double paramDouble1, double paramDouble2)
  {
    Logger.d("INRY", "W=" + paramDouble1 + ", H=" + paramDouble2);
    if (((paramDouble1 == 4680.0D) && (paramDouble2 == 3456.0D)) || ((paramDouble1 == 3456.0D) && (paramDouble2 == 4680.0D))){
    	return  "16 M";
		}
    else if (((paramDouble1 == 4680.0D) && (paramDouble2 == 3072.0D)) || ((paramDouble1 == 3072.0D) && (paramDouble2 == 4680.0D))){
    	return "14 MP";
      }
    else if (((paramDouble1 == 4320.0D) && (paramDouble2 == 3240.0D)) || ((paramDouble1 == 3240.0D) && (paramDouble2 == 4320.0D))){
    	return "14 M";
      }
    else if (((paramDouble1 == 4608.0D) && (paramDouble2 == 2592.0D)) || ((paramDouble1 == 2592.0D) && (paramDouble2 == 4608.0D))){
    	return "12 MW";
      }
    else if (((paramDouble1 == 4320.0D) && (paramDouble2 == 2880.0D)) || ((paramDouble1 == 2880.0D) && (paramDouble2 == 4320.0D))){
    	return "12 MP";
      }
    else  if (((paramDouble1 == 4320.0D) && (paramDouble2 == 2432.0D)) || ((paramDouble1 == 2432.0D) && (paramDouble2 == 4320.0D))){
    	return "10 MW";
      }
    else if (((paramDouble1 == 3648.0D) && (paramDouble2 == 2736.0D)) || ((paramDouble1 == 2736.0D) && (paramDouble2 == 3648.0D))){
    	return "10 M";
      }
    else if (((paramDouble1 == 2832.0D) && (paramDouble2 == 2832.0D)) || ((paramDouble1 == 2832.0D) && (paramDouble2 == 2832.0D))){
    	return "8 M";
      }
    else if (((paramDouble1 == 2592.0D) && (paramDouble2 == 1944.0D)) || ((paramDouble1 == 1944.0D) && (paramDouble2 == 2592.0D))){
    	return "5 M";
      }
    else if (((paramDouble1 == 1984.0D) && (paramDouble2 == 1488.0D)) || ((paramDouble1 == 1488.0D) && (paramDouble2 == 1984.0D))){
    	return "3 M";
      }
      if (((paramDouble1 == 1920.0D) && (paramDouble2 == 1080.0D)) || ((paramDouble1 == 1080.0D) && (paramDouble2 == 1920.0D))){
    	  return "2 MW";
      }
      else if (((paramDouble1 == 1024.0D) && (paramDouble2 == 768.0D)) || ((paramDouble1 == 768.0D) && (paramDouble2 == 1024.0D))){
    	  return "1 M";
       }
      else{
    	  return "10 M";  
      }
      

  }
}
